package com.sig.formes;

import java.util.ArrayList;


public class Polyedre extends Forme{

	public ArrayList<Point> points = new ArrayList<Point>(); 
	public ArrayList<Triangle> triangles = new ArrayList<Triangle>(); 
	
	public Polyedre(float[] color,Point...points){
		ArrayList<Point> out = new ArrayList<Point>();
		for(Point p:points){
			out.add(p);
		}
		creer(out,color);
	}

	public Polyedre(ArrayList<Point> points,float[] color) {
		creer(points,color);
	}

	private void creer(ArrayList<Point> points,float[] color){
		this.points = points;
		
		this.triangles = EarCutting.cut( points, false );
		
		for(int i=0 ; i< triangles.size();i++){
			triangles.get(i).setColor(color);
		}
	}

	public void draw(float[] mvpMatrix) {
		super.draw(mvpMatrix);
		for(Triangle triangle : triangles )
			triangle.draw(mvpMatrix);
	}
	
	@Override
	public void recreer(){
		for(Triangle triangle : triangles )
			triangle.recreer();
	}
}